package cn.bugstack.springframework.beans.factory.config;

import cn.bugstack.springframework.beans.BeansException;
import cn.bugstack.springframework.beans.factory.BeanFactory;


/**
 * <p>reference: DerekYRC https://github.com/DerekYRC/mini-spring
 * <p>Extension of the {@link BeanFactory} interface to be implemented by bean factories that are capable of
 * autowiring, provided that they want to expose this functionality for existing bean instances.
 *
 * @author Yaxi.Zhang
 * @since 2022/12/13 20:38
 */
public interface AutowireCapableBeanFactory extends BeanFactory {

    /**
     * 执行 BeanPostProcessors 接口实现类的 postProcessBeforeInitialization 方法
     *
     * @param existingBean 已经存在的bean
     * @param beanName     bean名称
     * @return 构建的bean对象
     * @throws BeansException bean异常
     */
    Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException;

    /**
     * 执行 BeanPostProcessors 接口实现类的 postProcessorsAfterInitialization 方法
     *
     * @param existingBean 已经存在的bean
     * @param beanName     bean名称
     * @return 构建的bean对象
     * @throws BeansException bean异常
     */
    Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws BeansException;

}
